//===================================
//File: Body.cpp
//Body function
//Name: Smirnova O.P.
//Date: 21.05.12, v.1.0
//===================================




#include "Body.h"


using namespace std;

//---------------------------------------------------------------------------

unsigned int Body::count=0;
unsigned int Body::count_all=0;
Body::Body()
{
	count_all++;
    id=count_all;
	count++;
    cout << endl;
//	cout << "\Body() ";
//	cout <<" id=" <<id<<":\n";
	trapeze = Trapeze();

//	cout << "a: " << trapeze.getA() << "\n";
//	cout << "d: " << trapeze.getD() << "\n";
//	cout << "h: " << trapeze.getH() << "\n";
///	cout << "P1: " << trapeze.getPoint1() << "\n";
//	cout << "P2: " << trapeze.getPoint2() << "\n";
//	cout << "P3: " << trapeze.getPoint3() << "\n";
//	cout << "P4: " << trapeze.getPoint4() << "\n";
//	cout << "Body()\n";
//	cout <<" id=" <<id<<endl;

}
// "Говорящий" конструктор с параметрами
Body::Body( Point C,  double h, double b,double c )
{
	count_all++;
    id=count_all;
	count++;
    cout << endl;
//	cout << "\Body() ";
//	cout <<" id=" <<id<<":\n";
	trapeze = Trapeze(C,h,b,c);
//	cout << "a: " << trapeze.getA() << "\n";
//	cout << "d: " << trapeze.getD() << "\n";
//	cout << "h: " << trapeze.getH() << "\n";
//	cout << "P1: " << trapeze.getPoint1() << "\n";
//	cout << "P2: " << trapeze.getPoint2() << "\n";
//	cout << "P3: " << trapeze.getPoint3() << "\n";
//	cout << "P4: " << trapeze.getPoint4() << "\n";
//	cout << "Body()\n";
//	cout <<" id=" <<id<<endl;
	
}
//---------------------------------------------------------------------------
Body::~Body()
{
	//cout << "\n~Body:\n";
	
	//cout << "~Body\n";
	
}
//---------------------------------------------------------------------------
void Body::moveTo( Point p)
{
	double x0, y0,x1,y1,x2,y2,x3,y3,x4,y4;
	x0=p.getX();
	y0=p.getY();
	x1=trapeze.getPointA().getX();
	y1=trapeze.getPointA().getY();
	x2=trapeze.getPointB().getX();
	y2=trapeze.getPointB().getY();
	x3=trapeze.getPointC().getX();
	y3=trapeze.getPointC().getY();
	x4=trapeze.getPointD().getX();
	y4=trapeze.getPointD().getY();
	trapeze.getPointA().moveToPoint(Point(x0-x1+x3,y0-y1+y3,0));
	trapeze.getPointB().moveToPoint(Point(x0-x2+x3,y0-y2+y3,0));
	trapeze.getPointD().moveToPoint(Point(x0-x4+x3,y0-y4+y3,0));
	trapeze.getPointC().moveToPoint(p);
};
//---------------------------------------------------------------------------
void Body::moveTodXdY( double  x, double y)
{
	trapeze.getPointA().moveTodXdY(x,y);
	trapeze.getPointB().moveTodXdY(x,y);
	trapeze.getPointC().moveTodXdY(x,y);
	trapeze.getPointD().moveTodXdY(x,y);
}; 

//---------------------------------------------------------------------------
void Body::consSF(Point P)
{
	trapeze.getPointA().consSP(P);
	trapeze.getPointB().consSP(P);
	trapeze.getPointC().consSP(P);
	trapeze.getPointD().consSP(P);
};
Trapeze Body::getTrapeze () 
{
	return trapeze;
};
//---------------------------------------------------------------------------
const unsigned int Body::getID()
{
  return id;
};
//---------------------------------------------------------------------------
unsigned int Body::countObject()
{
  return count; 
};
